#include <iostream>
#include <stdio.h>

#include "core.h"

#include <math.h>

using namespace std;
using namespace FPmath;

int main()
{
	char temp;
    Fixed a,b,c,d;
    a=1.505f;
    b=(short)2;
    c=10/3.0f;
    d=20/3.0f;
    //cout << a << " + " << b << " = " << (a+b) << endl;
    cout << "testing " << a << " , " << b << " , " << c << ", " << d << endl;
    printf("Values are %i, %hi, %f, %lf\n", (int)a, (short)b, (float)c, (float)d);

    a+=5;
    b+=(short)10;
    c+=20/3.0f;
    d+=10/3.0f;
    printf("After addition %i, %hi, %f, %lf\n", (int)a, (short)b, (float)c, (float)d);

    a-=5;
    b-=(short)10;
    c-=20/3.0f;
    d-=10/3.0f;
    printf("Subtraction %i, %hi, %f, %lf\n", (int)a, (short)b, (float)c, (float)d);

    a*=5;
    b*=(short)5;
    c*=5.0f;
    d*=5.0f;
    printf("Multiplication %i, %hi, %f, %lf\n", (int)a, (short)b, (float)c, (float)d);

    a/=5;
    b/=(short)5;
    c/=5.0f;
    d/=5.0f;
    printf("Division %i, %hi, %f, %lf\n", (int)a, (short)b, (float)c, (float)d);


    a-=30;
    b=abs(a);
    c=PI;
    printf("abs of b=%i, a=%i, pi=%f\n", (int)b, (int)a, (float)c);

    a=2.8f;
    b=3.0f;
    printf("floor of %f is %f, %f : %f is %f, %f\n", (float)a, (float)floor(a), (float)floor(-a),
        (float)b, (float)floor(b), (float)floor(-b));
    printf("ceil of %f is %f, %f : %f is %f, %f\n", (float)a, (float)ceil(a), (float)ceil(-a),
        (float)b, (float)ceil(b), (float)ceil(-b));

    a=0;
    b=PI/2;
    c=-b;
    d=3*PI/2;
    printf("sin of %f pi=%f %f pi=%f %f pi=%f %f pi=%f\n", (float)(a/PI), (float)sin(a), (float)(b/PI), (float)sin(b),
        (float)(c/PI), (float)sin(c), (float)(d/PI), (float)sin(d));

    a=2;
    b=-20;
    c=100;
    d=1000;
    printf ("sqrt of 2= %f, %f, %f\n", (float)sqrt(a), (float)sqrt2(a), sqrt(2.0));
    printf ("sqrt of -20= %f, %f, %f\n", (float)sqrt(b), (float)sqrt2(b), sqrt(-20.0));
    printf ("sqrt of 100= %f, %f, %f\n", (float)sqrt(c), (float)sqrt2(c), sqrt(100.0));
    printf ("sqrt of 1000= %f, %f, %f\n", (float)sqrt(d), (float)sqrt2(d), sqrt(1000.0));

    a=23;
    b=3;
    c=2;
    d=2.5f;
    printf ("23 mod 3 = %i,  4 mod 2 = %i, 6 mod 2.5 = %f\n", (int)(a%b), (int)((2*c)%c), (float)((b*2)%d));

    Recoil_core engine;
    engine.test.data.position.y=100;
    cout << "x=" << engine.test.data.position.x << " y=" << engine.test.data.position.y << endl;
    while (engine.test.data.position.y>0)
    {
        engine.update(0.1f);
        cout << "x=" << engine.test.data.position.x << " y=" << engine.test.data.position.y << endl;

    }
	cin >> temp;
    return 0;
}
